home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 November / macformat-018.iso / Utility Spectacular / Developer / macgzip_022-src / macos / Posix / ThinkCPosix Sources / CloseFiles.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-26  |  718 b   |  27 lines  |  [TEXT/MPS ]

  1. /*
  2.  * This version of MF allows a number of .mf files to be processed successively,
  3.  * taking advantage of a facility introduced by Knuth --
  4.  * but rarely if ever used nowadays --
  5.  * to run TeX or MF from core-dumps already initialized.
  6.  *
  7.  * Unfortunately, for some reason I have been unable to establish,
  8.  * MF does not always close all its open files.
  9.  * The number of open files builds up on successive runs,
  10.  * until finally the number exceeds the maximum allowable.
  11.  *
  12.  * This little Think C function closes all open files.
  13.  */
  14.  
  15. #include <stdio.h>
  16.  
  17. void closeallfiles(void);
  18.  
  19. void closeallfiles(void)
  20. {
  21.   int fd;
  22.   
  23.   for (fd = 4; fd <= FOPEN_MAX; fd++)
  24.     if (__file[fd].refnum)
  25.       fclose(&__file[fd]);
  26. }
  27.